package br.senac.notafiscal.service;

import java.util.List;

import br.senac.notafiscal.dao.ClienteDAO;
import br.senac.notafiscal.entity.Cliente;

public class ClienteService {
	
	private ClienteDAO clienteDao;
	
	public ClienteService() {
		clienteDao = new ClienteDAO();
	}
	
	public void salvarCliente(Cliente cliente)
	{
		clienteDao.persist(cliente);
	}
	
	public Cliente buscarCliente(Cliente cliente)
	{
		return clienteDao.getById(cliente.getId());
	}
	
	public List<Cliente> listarClientes()
	{
		return clienteDao.findAll();
	}
	
	public void excluirCliente(Cliente clienteDetached)
	{
		Cliente cliente = clienteDao.getById(clienteDetached.getId());
		clienteDao.remove(cliente);
	}
	
	public Cliente getById(Long id)
	{
		return clienteDao.getById(id);
	}
}
